package com.qf.util;

import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

/**
 * @version : 1.0
 * @author:宋煜
 * @date: 2022/4/12 12:52
 */
@Data
@ToString
@NoArgsConstructor
public class ResponseData<T> {
    private String code;
    private String msg;
    private T data;

    public ResponseData(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public ResponseData(String code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }
    public static ResponseData success(String code, String msg){
        return new ResponseData(code,msg);
    }
    public static ResponseData success(){
        return new ResponseData(ResponseCode.SUCCESS.getCode(),ResponseCode.SUCCESS.getMsg());
    }
    public static <T> ResponseData success(T data){
        return new ResponseData(ResponseCode.SUCCESS.getCode(),ResponseCode.SUCCESS.getMsg(),data);
    }
    public static ResponseData failure(){
        return new ResponseData(ResponseCode.FAILURE.getCode(),ResponseCode.FAILURE.getMsg());
    }
}
